package com.modules.websocket;

import java.util.List;
import java.util.Map;

public class WebSocketThread extends Thread{
	private int i;
	private String to;
	private String message;
	private List<Map<String, WebSocket>> clientList;
	public WebSocketThread(int i,List<Map<String, WebSocket>> clientList,String to, String message) {
		this.i = i;
		this.to = to;
		this.message = message;
		this.clientList = clientList;
	}
	@Override
	public void run() {
		if (!to.equals("All")){ // 指定-大数据
			Map<String, WebSocket> clien = clientList.get(i);
			for (WebSocket item : clien.values()) {
				if (item.uuid.equals(to) )
					item.session.getAsyncRemote().sendText(message); 
			}
        }else{ // 所有
        	Map<String, WebSocket> clien = clientList.get(i);
    		for (WebSocket item : clien.values()) {
    			item.session.getAsyncRemote().sendText(message); 
    		}
        }  
		
	}
}